﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Security.Cryptography;
using System.Configuration;
using System.Windows.Forms;
using System.IO;
using System.Data;
using System.Drawing.Printing;

namespace AutoBackupDatabase.General
{
    public class general
    {
        public static bool isAdministrator=false;

        public static int TableId;
        public static int itemId;
        public static string userName = "";
        public static int empId = 1;
        public static string EXPORTID;

        public static int tableIdJoin;
        public static DateTime DateCreate;
        public static DateTime DatePaid;
        public static string tableName;
        public static string areaName;

        public static int groupUserCode;

        public static bool SuccessFlag = false;

        #region Print Setting
        public static string PrinterBillName = "POS-58";
        public static string PrinterReportName = "";
        #endregion
        #region Print Setting Bill
        public static string titlePrint = "Trà Sữa Trân Châu";
        public static bool isTitlePrint = true;

        public static string logoTextPrint = "SOKUL";
        public static bool isLogoTextPrint = false;

        public static bool isLogoImagePrint = true;

        public static bool isDatePrint = true;
        public static bool isTimeInPrint = true;
        public static bool isTimeOutPrint = true;
        public static bool isTablePrint = true;
        public static bool isExportIdPrint = true;
        public static bool isCustomerPrint = true;
        public static bool isTotalPrint = true;
        public static bool isTotalDiscount = true;
        public static bool isTotalPayPrint = true;
        public static bool isSayGoodByePrint = true;
        public static string isSayGoodByeText1 = "Cảm ơn quý khách !";
        public static string isSayGoodByeText2 = "Hẹn gặp lại !";
        public static bool isWebsitePrint = false;
        public static bool isDiscountInfomationPrint = false;
        public static string WebsitePrintTest = "";
        public static string DiscountInfomationPrintTest = "";

        #endregion

        #region shortcut
          public static string  SLIPT="";
                public static string  JOIN="";
        public static string  NEWTABLE="";
        public static string  PAID="";
        public static string  PRINTAGAIN="";
        public static string  PRINTNOTPAY="";
        public static string  REPORT="";
        public static string  CHANGEPASS="";
        public static string  HELP="";
        #endregion


        public static string GetStartupPath()
        {
            return Application.StartupPath;
        }
        public static void ChangeButtonStatus(string ActionName, object btninsertName, object btnUpdateName, object btndelname)
        {
            if (ActionName == "insert" && ((DevExpress.XtraEditors.SimpleButton)btninsertName).Text == "THÊM MỚI")
            {
                ((DevExpress.XtraEditors.SimpleButton)btninsertName).Text = "LƯU";
                ((DevExpress.XtraEditors.SimpleButton)btnUpdateName).Text = "HỦY";
                ((DevExpress.XtraEditors.SimpleButton)btndelname).Enabled = false;
                return;
                ;
            }
            else if (ActionName == "insert" && ((DevExpress.XtraEditors.SimpleButton)btninsertName).Text == "LƯU")
            {
                ((DevExpress.XtraEditors.SimpleButton)btninsertName).Text = "THÊM MỚI";
                ((DevExpress.XtraEditors.SimpleButton)btnUpdateName).Text = "CẬP NHẬT";
                ((DevExpress.XtraEditors.SimpleButton)btndelname).Enabled = true;
                return;
            }
            else if (ActionName == "update" && ((DevExpress.XtraEditors.SimpleButton)btnUpdateName).Text == "HỦY")
            {
                ((DevExpress.XtraEditors.SimpleButton)btninsertName).Text = "THÊM MỚI";
                ((DevExpress.XtraEditors.SimpleButton)btnUpdateName).Text = "CẬP NHẬT";
                ((DevExpress.XtraEditors.SimpleButton)btndelname).Enabled = true;
                return;
            }
            else if (ActionName == "update" && ((DevExpress.XtraEditors.SimpleButton)btnUpdateName).Text == "CẬP NHẬT")
            {
                ((DevExpress.XtraEditors.SimpleButton)btninsertName).Enabled = false;
                ((DevExpress.XtraEditors.SimpleButton)btnUpdateName).Text = "LƯU";
                ((DevExpress.XtraEditors.SimpleButton)btndelname).Text = "HỦY";
                return;
            }
            else if (ActionName == "update" && ((DevExpress.XtraEditors.SimpleButton)btnUpdateName).Text == "LƯU")
            {
                ((DevExpress.XtraEditors.SimpleButton)btninsertName).Enabled = true;
                ((DevExpress.XtraEditors.SimpleButton)btnUpdateName).Text = "CẬP NHẬT";
                ((DevExpress.XtraEditors.SimpleButton)btndelname).Text = "XÓA";
                return;
            }
            else if (ActionName == "delete" && ((DevExpress.XtraEditors.SimpleButton)btndelname).Text == "HỦY")
            {
                ((DevExpress.XtraEditors.SimpleButton)btninsertName).Enabled = true;
                ((DevExpress.XtraEditors.SimpleButton)btnUpdateName).Text = "CẬP NHẬT";
                ((DevExpress.XtraEditors.SimpleButton)btndelname).Text = "XÓA";
                return;
            }
            else if (ActionName == "insert" && ((DevExpress.XtraEditors.SimpleButton)btndelname).Text == "HỦY")
            {
                return;
            }


        }

        public static DataTable GetDefaultPrinter()
        {
            var dt = new DataTable();
            DataColumn printerName = new DataColumn("PrinterName");
            dt.Columns.Add(printerName);
            DataRow r;
            foreach (string printer in PrinterSettings.InstalledPrinters)
            {
                r = dt.NewRow();
                r["PrinterName"] = printer;
                dt.Rows.Add(r);
            }
            return dt;
        }
    }
}
